<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>图片预览</title>
 <script  type="text/javascript">
 function onLoad() { 
     var picSrc = window.parent.picSrc; 
     var picWidth = window.parent.picWidth; 
     var picHeight = window.parent.picHeight; 
     if(picWidth>picHeight){
   		width = 592;
   		height = picHeight*width/picWidth;
   		
   		marginTop = parseInt((width-height)/2);
   		margin = marginTop+"px 0 0 0;";
    }else{    	
   		height = 592;
   		width = picWidth*height/picHeight;    		
   		marginLeft = parseInt((height-width)/2);
   		margin = "0 0 0 "+marginLeft+"px;";    		
    }
    alert("<img src="+picSrc+" style='width:"+width+"px;height:"+height+"px;margin:"+margin+"'/>");
    document.getElementById("imgWrap").innerHTML = "<img src="+picSrc+" style='width:"+width+"px;height:"+height+"px;margin:"+margin+"'/>";
     
 } 
  </script>
  <style type="text/css">
  html,body{padding:0;margin:0;text-align:center;}
  #imgWrap{margin:0 auto;}
  </style>
</head>
<body onload='onLoad'>
	<div id="imgWrap">
	<img alt="" src="http://pic1a.nipic.com/2008-12-09/20081291733215_2.jpg">
	</div>
</body>
</html>
